#!/bin/bash

_help_message() {
        printf "\
Generates a list of affected packages for topic pull requests.

Usage:

        genaffect PACKAGE_GROUP

        - PACKAGE_GROUP: Path to the list of packages to generate affected list from.
          (Example: TREE/groups/plasma)

"
}

if [[ "$1" == "--help" || "$1" == "-h" ]]; then
        _help_message
        exit 0
fi

if [ -z "$1" ]; then
        echo -e "[!!!] Please specify a package group.\n"
        _help_message
        exit 1
fi

for i in `cat $1`; do
	source $i/spec
	printf -- "- \`$(echo $i | cut -f2 -d/)\` v${VER}-${REL:-0}\n"
done | sort
